package com.totem.customer.serivce.auth;

import com.totem.base.security.Authentication;
import com.totem.base.security.model.MobilepasswordAuthentication;
import com.totem.base.security.model.MobilepasswordCertification;
import com.totem.base.security.model.UsernamepasswordCertification;
import com.totem.customer.model.TCustomers;
import com.totem.customer.serivce.IAuthService;
import com.totem.customer.serivce.ITCustomerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service("mobileAuthenticationService")
public class MobileAuthServiceImpl extends MobilepasswordAuthentication implements IAuthService {
    @Autowired
    private ITCustomerService itCustomerService;

    protected MobilepasswordCertification findByMobile(String countryCode, String mobile) {
        TCustomers tCustomers = itCustomerService.findByMobile(countryCode, mobile);
        if(tCustomers==null) return null;
        MobilepasswordCertification another = new MobilepasswordCertification(tCustomers.getCountryCode(), tCustomers.getMobile(), tCustomers.getPassword());
        another.setId(tCustomers.getId());
        return another;
    }
}
